import deepClone from './深拷贝.js';
console.log(deepClone);
const arr = [1, 2, 3];
const obj = { name: 'aaa' };
Array.prototype.myForEach = function (cb) {
    let _target = arguments[1] || window,
        _len = this.length;
    for (let i = 0; i < _len; i++) {
        cb.apply(_target, [this[i], i, this]);
    }
}

Array.prototype.myMap = function(cb){
    let _target = arguments[1] || window,
        _len = this.length;
        _this = deepClone(this);
        newArr = [];
    for (let i = 0; i < _len; i++) {
        newArr.push(cb.apply(_target, [_this[i], i, _this]));
    }
    return newArr ;
}

//  test-----------------
arr.map(function (item, index, array) {
    console.log(this, item, index, array);
}, obj);
console.log('-------------------------------------');
arr.myForEach((item, index, array)=> {
    console.log(this, item, index, array);
}, obj);